<%@ page import="com.studentachievement.beans.Score" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: JYF_ASUS
  Date: 2024/11/30
  Time: 下午7:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理员管理系统</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            display: flex;
            background-color: #f4f4f9;
        }
        .sidebar {
            width: 250px;
            background-color: #45a049;
            color: #ecf0f1;
            padding: 15px;
            height: 100vh;
            position: fixed;
        }
        .sidebar h2 {
            text-align: center;
            margin-bottom: 30px;
        }
        .sidebar ul {
            list-style-type: none;
            padding: 0;
        }
        .sidebar ul li {
            margin: 10px 0;
        }
        .sidebar ul li a {
            color: #ecf0f1;
            text-decoration: none;
            font-size: 18px;
            padding: 10px;
            display: block;
            border-radius: 5px;
            transition: background-color 0.3s;
        }
        .sidebar ul li a:hover {
            background-color: #34495e;
        }
        .content {
            margin-left: 250px;
            padding: 30px;
            width: 100%;
        }
        .form-container {
            background-color: #fff;
            border-radius: 8px;
            padding: 20px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            margin-bottom: 20px;
        }
        .form-container h3 {
            margin-bottom: 15px;
            color: #4CAF50;
        }
        label {
            font-weight: bold;
            display: block;
            margin: 10px 0 5px;
        }
        input[type="text"], input[type="password"], input[type="date"], input[type="number"] {
            width: 100%;
            padding: 8px;
            margin-bottom: 20px;
            border: 1px solid #ccc;
            border-radius: 5px;
        }
        button {
            background-color: #4CAF50;
            color: #ecf0f1;
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        button:hover {
            background-color: #4CAF50;
        }
        .button-container {
            text-align: center;
        }
        h1 {
            color: #2c3e50;
        }

    </style>
</head>
<body>
<!-- 顶部导航栏 -->
<div class="navbar">
    <h1>管理员管理系统</h1>
    <div>
        <a href="admin_home.jsp?section=student">学生管理</a>
        <a href="admin_home.jsp?section=course">课程管理</a>
        <a href="admin_home.jsp?section=score">成绩管理</a>
    </div>
</div>

<!-- 左侧侧边栏 -->
<div class="sidebar">
<%--    <h2>管理员操作</h2>--%>
    <ul>
        <br><br>
        <li><a href="admin_home.jsp?section=student">学生管理</a></li>
        <br>
        <li><a href="admin_home.jsp?section=course">课程管理</a></li>
        <br>
        <li><a href="admin_home.jsp?section=score">成绩管理</a></li>
        <br>
<%--        <li><a href="${pageContext.request.contextPath}/AdminSelectAllServlet" target="_blank">查看信息</a></li>--%>
    </ul>
</div>

<!-- 右侧内容区 -->
<div class="content">
<%--    <h1>管理员操作界面</h1>--%>

    <%
        // 获取页面传递的请求参数 "section"
        String section = request.getParameter("section");
        if (section == null) {
            section = "student";  // 默认显示学生管理
        }

        // 根据不同的功能来显示不同的表单
        if (section.equals("student")) {
    %>
    <h2>&nbsp;&nbsp;学生管理</h2>

    <!-- 删除学生 -->
    <div class="form-container">
        <h3>删除学生</h3>
        <form action="${pageContext.request.contextPath}/AdminHomeServlet" method="post">
            <label for="student_id_delete">学号:</label>
            <input type="text" id="student_id_delete" name="student_id" required>
            <button type="submit" name="action" value="delete_student">删除学生</button>
        </form>
    </div>

    <!-- 搜索学生 -->
    <div class="form-container">
        <h3>搜索学生</h3>
        <form action="${pageContext.request.contextPath}/AdminHomeServlet" method="post">
            <label for="student_id_search">学号:</label>
            <input type="text" id="student_id_search" name="student_id" required>
            <button type="submit" name="action" value="search_student">搜索学生</button>
        </form>
    </div>

    <!-- 添加学生 -->
    <div class="form-container">
        <h3>添加学生</h3>
        <form action="${pageContext.request.contextPath}/AdminHomeServlet" method="post">
            <label for="student_name_add">姓名:</label>
            <input type="text" id="student_name_add" name="name" required>
<%--            <label for="student_id_add">学号:</label>--%>
<%--            <input type="text" id="student_id_add" name="student_id" required>--%>
            <label for="student_gender_add">性别:</label>
            <input type="text" id="student_gender_add" name="gender" required>
            <label for="student_birth_date_add">出生日期:</label>
            <input type="date" id="student_birth_date_add" name="birth_date">
            <label for="student_major_add">专业:</label>
            <input type="text" id="student_major_add" name="major">
            <label for="student_password_add">密码:</label>
            <input type="password" id="student_password_add" name="password">
            <button type="submit" name="action" value="add_student">添加学生</button>
        </form>
    </div>

    <!-- 修改学生信息 -->
    <div class="form-container">
        <h3>修改学生信息</h3>
        <form action="${pageContext.request.contextPath}/AdminHomeServlet" method="post">
            <label for="student_id_modify">学号:</label>
            <input type="text" id="student_id_modify" name="student_id" required>
            <label for="student_name_modify">姓名:</label>
            <input type="text" id="student_name_modify" name="name">
            <label for="student_gender_modify">性别:</label>
            <input type="text" id="student_gender_modify" name="gender">
            <label for="student_birth_date_modify">出生日期:</label>
            <input type="date" id="student_birth_date_modify" name="birth_date">
            <label for="student_major_modify">专业:</label>
            <input type="text" id="student_major_modify" name="major">
            <label for="student_password_modify">密码:</label>
            <input type="password" id="student_password_modify" name="password">
            <button type="submit" name="action" value="update_student">修改学生</button>
        </form>
    </div>
    <%
    } else if (section.equals("course")) {
    %>
    <h2>&nbsp;&nbsp;课程管理</h2>

    <!-- 删除课程 -->
    <div class="form-container">
        <h3>删除课程</h3>
        <form action="${pageContext.request.contextPath}/AdminHomeServlet" method="post">
            <label for="course_id_delete">课程号:</label>
            <input type="text" id="course_id_delete" name="course_id" required>
            <button type="submit" name="action" value="delete_course">删除课程</button>
        </form>
    </div>

    <!-- 搜索课程 -->
    <div class="form-container">
        <h3>搜索课程</h3>
        <form action="${pageContext.request.contextPath}/AdminHomeServlet" method="post">
            <label for="course_id_search">课程号:</label>
            <input type="text" id="course_id_search" name="course_id" required>
            <button type="submit" name="action" value="search_course">搜索课程</button>
        </form>
    </div>

    <!-- 添加课程 -->
    <div class="form-container">
        <h3>添加课程</h3>
        <form action="${pageContext.request.contextPath}/AdminHomeServlet" method="post">
            <label for="course_name_add">课程名:</label>
            <input type="text" id="course_name_add" name="course_name" required>
            <label for="course_id_add">课程号:</label>
            <input type="text" id="course_id_add" name="course_id" required>
            <label for="teacher_name_add">授课教师:</label>
            <input type="text" id="teacher_name_add" name="teacher_name">
            <label for="credits_add">学分:</label>
            <input type="number" id="credits_add" name="credits">
            <button type="submit" name="action" value="add_course">添加课程</button>
        </form>
    </div>

    <!-- 修改课程 -->
    <div class="form-container">
        <h3>修改课程</h3>
        <form action="${pageContext.request.contextPath}/AdminHomeServlet" method="post">
            <label for="course_name_modify">课程名:</label>
            <input type="text" id="course_name_modify" name="course_name">
            <label for="course_id_modify">课程号:</label>
            <input type="text" id="course_id_modify" name="course_id" required>

            <label for="teacher_name_modify">授课教师:</label>
            <input type="text" id="teacher_name_modify" name="teacher_name">
            <label for="credits_modify">学分:</label>
            <input type="number" id="credits_modify" name="credits">
            <button type="submit" name="action" value="update_course">修改课程</button>
        </form>
    </div>
    <%
    } else if (section.equals("score")) {
    %>
    <h2>&nbsp;&nbsp;成绩管理</h2>

    <!-- 删除成绩 -->
    <div class="form-container">
        <h3>删除成绩</h3>
        <form action="${pageContext.request.contextPath}/AdminHomeServlet" method="post">
            <label for="student_id_score_delete">学号:</label>
            <input type="text" id="student_id_score_delete" name="student_id" required>
            <label for="course_id_score_delete">课程号:</label>
            <input type="text" id="course_id_score_delete" name="course_id" required>
            <button type="submit" name="action" value="delete_score">删除成绩</button>
        </form>
    </div>

    <!-- 搜索成绩 -->
    <div class="form-container">
        <h3>搜索成绩</h3>
        <form action="${pageContext.request.contextPath}/AdminHomeServlet" method="post">
            <label for="student_id_score_search">学号:</label>
            <input type="text" id="student_id_score_search" name="student_id" required>
            <label for="course_id_score_search">课程号:</label>
            <input type="text" id="course_id_score_search" name="course_id" required>
            <button type="submit" name="action" value="search_score">搜索成绩</button>
        </form>
    </div>

    <!-- 添加成绩 -->
    <div class="form-container">
        <h3>添加成绩</h3>
        <form action="${pageContext.request.contextPath}/AdminHomeServlet" method="post">
            <label for="student_id_add_score">学号:</label>
            <input type="text" id="student_id_add_score" name="student_id" required>
            <label for="course_id_add_score">课程号:</label>
            <input type="text" id="course_id_add_score" name="course_id" required>
            <label for="score_add">分数:</label>
            <input type="text" id="score_add" name="score" required>
            <label for="exam_date_add">考试日期:</label>
            <input type="date" id="exam_date_add" name="exam_date">
            <button type="submit" name="action" value="add_score">添加成绩</button>
        </form>
    </div>

    <!-- 修改成绩 -->
    <div class="form-container">
        <h3>修改成绩</h3>
        <form action="${pageContext.request.contextPath}/AdminHomeServlet" method="post">
            <label for="student_id_modify_score">学号:</label>
            <input type="text" id="student_id_modify_score" name="student_id" required>
            <label for="course_id_modify_score">课程号:</label>
            <input type="text" id="course_id_modify_score" name="course_id" required>
            <label for="score_modify">分数:</label>
            <input type="text" id="score_modify" name="score" required>
            <label for="exam_date_modify">考试日期:</label>
            <input type="date" id="exam_date_modify" name="exam_date">
            <button type="submit" name="action" value="update_score">修改成绩</button>
        </form>
    </div>
    <%
        }
    %>
</div>
</body>
</html>
